import type { RouteLocationRaw } from 'vue-router'
import { ExperimentRouteMap } from './route'
import { RouterName } from '@/router/name'
import { LabID } from '@/constants/lab'

import type { ExperimentModel } from '@/apis/course'

export function getRouteLocation(
  experiment: ExperimentModel,
  classID: string | number
): RouteLocationRaw {
  const labID = experiment.id
  return getRouteLocationByLabID(labID, classID)
}

export function getRouteLocationByLabID(labID: LabID, classID: string | number): RouteLocationRaw {
  switch (labID) {
    case LabID.ReportUpload:
    case LabID.LabPreview:
    case LabID.MIMOSimulator:
    case LabID.MIMODebugger:
      return { name: ExperimentRouteMap[labID], params: { classID } }
    default:
      return { name: RouterName.NotFound }
  }
}
